#include <math.h>
#include "gaevaluator.h"
#include <memory.h>

#include "btree.h"

class gpev : public GAEvaluator
{
public:
    gpev(){}
    
    void Randomize(unsigned char* _g, long _iLen)
    {
      btree_randomise((char**)&_g, _iLen);
    }
    
    void Mutate(unsigned char* _g, long _iLen, float _fRatio, long _iAmount)
    {
      for(int i =0;i<_fRatio*_iLen; i++)
      {
          btree_mutate((char**)&_g, _iLen);
      }
    }
    
    float evaluate_single(float* input, unsigned char* _g, long _iLen)
    {
       return (float) btree_eval((char**)&_g, _iLen, input);
    }

		void print(unsigned char* _g, long _iLen)
		{
      btree_prg_print((char**)&_g, (char*)_g + _iLen);
		}

    int getSize() {return 16; }
    
    int getPop() {return 10;}
    
    float getTarget() { return 0.006f; }
    
    float getMutationRatio() { return 1.0f; }
    
    void toFile(unsigned char* _g, long _lSize, const char* file)
		{
      btree_save(file, (char*)_g, _lSize);
    }
};

extern "C" GAEvaluator* dimga_get_evaluator(){ return new gpev();}


